package com.rpp.session;

import com.rpp.config.XmlSqlMapCofigBuilder;
import com.rpp.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSesssionFactoryBuilder {

    public static SqlSessionFactory build(InputStream inputStream) throws PropertyVetoException, DocumentException {

        //解析sqlMapConfiguration.xml
        XmlSqlMapCofigBuilder xmlSqlMapCofigBuilder = new XmlSqlMapCofigBuilder();
        Configuration configuration = xmlSqlMapCofigBuilder.parse(inputStream);

        return new DefaultSqlSessionFactory(configuration);
    }
}
